package com.example.tg.Service.Impl;

import com.example.tg.Dao.PurchaseReturnMapper;
import com.example.tg.Service.PurchaseReturnService;
import com.example.tg.Service.PurchaselistService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import pojo.ListPo;
import pojo.Pr;
import pojo.PurchaseReturn;
import pojo.Xgzt;

import java.util.List;

@Service

public class PurchaseReturnServiceImpl implements PurchaseReturnService {
    @Autowired
    private PurchaseReturnMapper purchaseReturnMapper;
    @Autowired
    private PurchaselistService purchaselistService;

    @Override
    @Transactional
    public int addPr(Pr pr) {
        purchaseReturnMapper.addPr(pr.getPurchaseReturn());
        purchaselistService.addPl2(pr.getList());
        return 1;
    }

    @Override
    public int delePr(String  id) {
        return purchaseReturnMapper.delePr(id);
    }



    @Override
    public PageInfo<PurchaseReturn> listPr(ListPo listPo) {
        PageHelper.startPage(listPo.getPageNum(),listPo.getPageSize());
        List list= purchaseReturnMapper.listPr(listPo);
        PageInfo<PurchaseReturn> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public int contPr() {
        return purchaseReturnMapper.contPr();
    }

    @Override
    public PurchaseReturn showPr(String code) {
        return purchaseReturnMapper.showPr(code);
    }

    @Override
    @Transactional
    public int updaPr(Xgzt xgzt) {
        return purchaseReturnMapper.updaPr(xgzt);
    }
}
